<template>
  <div class="home">

    <!-- 上 -->
    <div class="home-top">
      <img class="bar" src="@/assets/bar.png" alt=""/>
      <!-- 用户信息-->
      <div class="user-info">
        <div class="user-name">
          <p class="nickname">{{ userInfo.nickname }}</p>
          <p class="intro">{{ userInfo.intro }}</p>
        </div>
        <div class="user-avatar">
          <img src="../assets/avatar.jpg">
        </div>
      </div>

      <!-- 用户数据 -->
      <div class="user-data">
        <ul>
          <li>
            <p class="tab-info-num">{{ userInfo.dynamicNum }}</p>
            <!--动态数量-->
            <span class="tab-info">动态</span></li>
          <li>
            <p class="tab-info-num">{{ userInfo.followingNum }}</p>
            <!--关注数量-->
            <span class="tab-info">关注</span></li>
          <li>
            <p class="tab-info-num">{{ userInfo.followerNum }}</p>
            <!--粉丝数量-->
            <span class="tab-info">粉丝</span></li>
        </ul>
      </div>
    </div>

    <!-- 主区域 -->
    <div class="home-main">
      <!-- 个人主页详细信息，包括收藏的小程序 -->
      <div class="home-collect-apps">
        <AlCell
            title="个人空间"
            icon="icon-user-space"
            @click="goSpace"
        ></AlCell>
      </div>

      <!-- 信息 -->
      <div class="share-data">
        <h6>信息</h6>
        <ul>

          <li>
            <p class="share-yesterday">
              ❤获赞
              <span class="num">
              ++{{ userInfo.shareData.like.yesterday }}
              </span>
            </p>
            <p class="share-num">{{ userInfo.shareData.like.total }}</p>
            <span class="share-info">获赞总数</span>
          </li>

          <li>
            <p class="share-yesterday">
              ⭐️收藏
              <span class="num">
                ++{{ userInfo.shareData.star.yesterday }}
              </span>
            </p>
            <p class="share-num">{{ userInfo.shareData.star.total }}</p>
            <span class="share-info">收藏总数</span>
          </li>

          <li>
            <p class="share-yesterday">✈️发布
              <span class="num">
              ++{{ userInfo.shareData.release.yesterday }}
              </span>
            </p>
            <p class="share-num">{{ userInfo.shareData.release.total }}</p>
            <span class="share-info">发布总数</span>
          </li>

        </ul>
      </div>

      <!-- 单元格 -->
      <div class="cell-list">
        <AlCell
            title="我的订单"
            icon="icon-gouwuche"
        ></AlCell>
        <AlCell
            title="我的收藏"
            icon="icon-collect"
        ></AlCell>
        <AlCell
            title="我的喜爱"
            icon="icon-like"
        ></AlCell>
        <AlCell
            title="设置"
            icon="icon-setting"
        ></AlCell>

      </div>
    </div>
  </div>
</template>

<script>

import AlCell from '@/components/AlCell'
import {mapState, mapGetters} from 'vuex'

export default {
  name: 'home',
  components: {AlCell},
  computed: {
    ...mapState(['userInfo']),
    ...mapGetters(['USER_AVATAR'])
  },
  methods: {
    goSpace() {
      this.$router.push('/space')
    }
  }
}
</script>

<style lang="less">

* {
  margin: 0;
  padding: 0;
}

.home {
  background-color: @bg-color;
  overflow: auto;
  padding: 43px 0 88px 0;

  .home-top {
    width: 375px;
    height: 161.25px;
    padding: 10px 0;
    background: linear-gradient(45deg, #33acf1, #1296ef);
    color: @white-color;

    .bar {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 44px;
      z-index: 999;
    }

    .user-info {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
      padding: 0 15px;

      .user-name {
        .nickname {
          font-size: 21px;
          font-weight: 600;
          margin-bottom: 10px;
        }

        .intro {
          opacity: 0.7;
          font-size: 12px;
        }
      }

      .user-avatar {
        img {
          width: 50px;
          height: 50px;
          border: 3px solid rgba(255, 255, 255, 0.38);
          border-radius: 50%;
        }
      }
    }

    .user-data {
      ul {
        display: flex;
        justify-content: space-around;
        align-items: center;

        li {
          display: flex;
          flex-direction: column;
          align-items: center;

          .tab-info-num {
            font-size: 21px;
            font-weight: 700;
          }

          .tab-info {
            width: 49px;
            opacity: 0.7;
            font-size: 12px;
          }
        }
      }
    }
  }


  .home-main {

    position: relative;
    padding: 0 15px;
    border: 1px solid transparent;

    .home-collect-apps {
      position: absolute;
      top: -30px;
      width: 345px;

    }

    .share-data {
      border-radius: 8px;
      background: @white-color;
      margin: 35px 0 10px 0;
      padding: 10px;

      h6 {
        margin-bottom: 10px;
      }

      ul {
        display: flex;
        justify-content: space-around;
        align-items: center;

        li {
          display: flex;
          flex-direction: column;
          align-items: center;

          .share-yesterday {
            font-size: 10px;
            color: @minor-font-color;
            margin-bottom: 5px;

            .num {
              color: @assist-color;
            }
          }

          .share-num {
            font-size: 21px;
            font-weight: 700;
            color: @main-font-color;
            margin: 10px 0;
          }

          .share-info {
            font-size: 12px;
            color: @subdominant-font-color;
          }
        }
      }
    }

    .cell-list {
      //border-radius: 10px;
      overflow: hidden;
    }

  }
}


</style>